﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_WebUserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userName"] != null)
        {
            object[] userInformation =  MemberInfo.getUserInfo(Session["userName"].ToString());

            lblFirst.Text= userInformation[0].ToString();
            lblLast.Text = userInformation[1].ToString();
            lblGender.Text = userInformation[2].ToString();
            lblAge.Text = userInformation[3].ToString();
            lblStreet.Text = userInformation[4].ToString();
            lblProv.Text = userInformation[5].ToString();
            lblCity.Text = userInformation[6].ToString();
            lblPostal.Text= userInformation[7].ToString();
            lblPhone.Text = userInformation[8].ToString();
            txtEmailAddr.Text = userInformation[9].ToString();
           // txtUserPwd.Text = userInformation[10].ToString();
            txtEmailAddr.Enabled = false;

        }
        else 
        {
            Response.Redirect("Oooops.aspx");
        }

    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (Session["userName"] != null)
        {
            MemberInfo.ExecuteUpdate(txtFirst.Text, txtLast.Text, ddlGen.SelectedItem.Text, int.Parse(txtUserAge.Text), txtStreet.Text, ddlProv.SelectedItem.Text,
                ddlUserCity.SelectedItem.Text, txtPostalCode.Text, txtPhoneNum.Text, txtUserPwd.Text, Session["userName"].ToString());

            Response.Redirect("UpdateSuccess.aspx");
        }
        else
        {
            Response.Redirect("Oooops.aspx");
        }
    }

    protected void lbFName_Click(object sender, EventArgs e)
    {
        txtFirst.Text = lblFirst.Text;
    }
    protected void lbLast_Click(object sender, EventArgs e)
    {
        txtLast.Text = lblLast.Text;
    }
    protected void lbGender_Click(object sender, EventArgs e)
    {
        ddlGen.SelectedItem.Text = lblGender.Text;
    }
    protected void lbAge_Click(object sender, EventArgs e)
    {
        txtUserAge.Text = lblAge.Text;
    }
    protected void lbStreet_Click(object sender, EventArgs e)
    {
        txtStreet.Text = lblStreet.Text;
    }
    protected void lbProv_Click(object sender, EventArgs e)
    {
        ddlProv.Focus();
    }
    protected void lbCity_Click(object sender, EventArgs e)
    {
        ddlUserCity.Focus();
    }
    protected void lbPostal_Click(object sender, EventArgs e)
    {
        txtPostalCode.Text = lblPostal.Text;
    }
    protected void lbPhone_Click(object sender, EventArgs e)
    {
        txtPhoneNum.Text = lblPhone.Text;
    }
}